package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.pojo.Permission;
import com.itheima.pojo.Role;
import com.itheima.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Select("select id,username,password from t_user where username = #{username} ")
    User findUserInfoByUsername(@Param("username") String username);
    
    @Select("select tr.id,tr.keyword " +
            "from t_role tr , t_user_role tur " +
            "where tr.id = tur.role_id " +
            "and tur.user_id=#{uid}")
    Set<Role> findRoleInfoByUserId(@Param("uid")Integer uid);

        @Select("SELECT tp.keyword " +
                "FROM t_permission tp , t_role_permission trp " +
                "where tp.id = trp.permission_id " +
                "and trp.role_id=#{rid}")
    Set<Permission> findPermissionInfoByRoleId(@Param("rid") Integer rid);
}
